package cn.com.zsw.gblog.config.dozer;

import com.github.dozermapper.core.DozerConverter;

/**
 * @author shiwangzhou
 * @date 2021-03-15
 **/
public class LongToStringDozerConverter extends DozerConverter<Long, String> {
    /**
     * Defines two types, which will take part transformation.
     * As Dozer supports bi-directional mapping it is not known which of the classes is source and
     * which is destination. It will be decided in runtime.
     *
     * @param prototypeA type one
     * @param prototypeB type two
     */
    public LongToStringDozerConverter(Class<Long> prototypeA, Class<String> prototypeB) {
        super(prototypeA, prototypeB);
    }

    /**
     * Converts the source field to the destination field and return the resulting destination
     * value.
     *
     * @param source      the value of the source field
     * @param destination the current value of the destination field (or null)
     * @return the resulting value for the destination field
     */
    @Override
    public String convertTo(Long source, String destination) {
        return String.valueOf(source);
    }

    /**
     * Converts the source field to the destination field and return the resulting destination
     * value
     *
     * @param source      the value of the source field
     * @param destination the current value of the destination field (or null)
     * @return the resulting value for the destination field
     */
    @Override
    public Long convertFrom(String source, Long destination) {
        return Long.valueOf(source);
    }
}